var path = require("path")
const conn = require("./conn.js")
const cuid = require("cuid")
module.exports = (req, res) => {
    if (!req.query.id) {
        // 对登录报错信息做了一个封装，这里调用
        require('./message')({
            status: 'error',
            msg: '来晚了，问卷作答已经结束'
        }, res)
        return
    }
    // 验证用户是否已经答过了
    var id = req.query.id
    if (req.cookies['releaseInfo' + id]) {
        require('./message')({
            status: 'error',
            msg: '您已经作过答问卷了'
        }, res)
        return
    } else {
        res.cookie('release_paper_id', id)
        res.cookie('releaseInfo' + id, JSON.stringify({
            paper_id: id,
            cuid: cuid()
        }))
    }
    res.sendFile(path.resolve("./") + "/public/release.html")
}